package net.huashitong.ssydt.provider.money.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.huashitong.ssydt.PaginationResult;
import net.huashitong.ssydt.money.entity.SsMoneyVip;
import net.huashitong.ssydt.money.entity.vo.SsMoneyVipQueryInVO;
import net.huashitong.ssydt.money.entity.vo.SsMoneyVipRecordInVO;
import net.huashitong.ssydt.provider.money.service.SsMoneyVipService;
import net.huashitong.ssydt.provider.web.model.Result;
import net.huashitong.ssydt.provider.web.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author hemj
 * @version 2017/8/21
 */
@Api(value = "/money/vip", tags = {"vip账户管理（后台）"})
@RestController
@RequestMapping("/money/vip")
public class SsMoneyVipController {
	@Autowired
	private SsMoneyVipService ssMoneyVipService;

	@ApiOperation(value = "vip账户列表", notes = "vip账户列表")
	@GetMapping
	public Result<PaginationResult<SsMoneyVip>> paginationQuery(@ModelAttribute SsMoneyVipQueryInVO ssMoneyVipQueryInVO) {
		return ResultUtils.getSuccessResults(ssMoneyVipService.paginationQuery(ssMoneyVipQueryInVO));
	}

	@ApiOperation(value = "vip账户套餐开通/延期", notes = "vip账户套餐开通/延期(后台管理)")
	@PutMapping("/{userId}")
	public Result<String> renewalEffectiveDay(@PathVariable String userId, @Valid SsMoneyVipRecordInVO ssMoneyVipRecordInVO) {
		ssMoneyVipService.renewalEffectiveDay(ssMoneyVipRecordInVO);
		return ResultUtils.getSuccessResults();
	}
}
